package common.model.po.base;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import common.config.datasource.DataSourceConstants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * PO实体类公共父类（主键策略：自增）
 *
 * @author 米泽鹏
 * @since 2021-07-27 3:58 下午
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class BasePo<T extends Model<?>> extends Model<T> {

	/**
	 * 主键
	 */
	@TableId(value = DataSourceConstants.ID_FIELD_NAME_IN_DATABASE, type = IdType.AUTO)
	private Long id;

	/**
	 * 操作人username
	 */
	@TableField(value = DataSourceConstants.OPERATOR_FIELD_NAME_IN_DATABASE, fill = FieldFill.INSERT_UPDATE)
	private String operator;

	/**
	 * 创建时间
	 */
	@TableField(value = DataSourceConstants.CREATE_TIME_FIELD_NAME_IN_DATABASE, updateStrategy = FieldStrategy.NEVER, fill = FieldFill.INSERT)
	@JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss.SSS")
	private Date createTime;

	/**
	 * 更新时间
	 */
	@Version
	@TableField(value = DataSourceConstants.UPDATE_TIME_FIELD_NAME_IN_DATABASE, fill = FieldFill.INSERT_UPDATE)
	@JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss.SSS")
	private Date updateTime;

}
